<!doctype html>
<html>
<head>
<meta charset="utf-8">
        

<title></title>
<style>
html, body{
	width:100%;
	height:100%;
	margin:0;
	padding:0;
	overflow:hidden;
}

</style>
<script src="./CSInterface.js"></script>
</head>

<body >
    <script>
        var http = require('http');
		var fs = require('fs');
		var cs = new CSInterface();
		var path = cs.getSystemPath( SystemPath.EXTENSION );

		http.createServer(function (req, res) {
		  var data, contentType;
		  if(req.url === '/') {
			data = fs.readFileSync(path + '/index.html');
			contentType = 'text/html';
		  } else {
			data = fs.readFileSync(path + req.url);
			var extension = req.url.substring(req.url.lastIndexOf('.') + 1);
			switch(extension){
				case 'svg':
					contentType = 'image/svg+xml'
					break;
				case 'jpg':
				case 'jpeg':
					contentType = 'image/jpeg'
					break;
				case 'png':
					contentType = 'image/png'
					break;
				case 'css':
					contentType = 'text/css'
					break;
				case 'js':
					contentType = 'text/javascript'
					break;
				case 'map':
					contentType = 'text/plain'
					break;
				case 'ttf':
					contentType = 'application/octet-stream'
					break;
			}
			if(contentType === undefined) {
				console.log(req)
				console.log('contentType: ', contentType)
			}
		  }
		  
		  res.writeHead(200, {'Content-Type': contentType});
		  res.end(data);
		}).listen(3117);
		window.location = "http://localhost:3117/";
    </script>
        
</body>
</html>
